/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kleintjes.behavioral.visitor_pattern.Impl;

import com.kleintjes.behavioral.visitor_pattern.NumberElement;
import com.kleintjes.behavioral.visitor_pattern.NumberVisitor;
import java.util.List;

/**
 *
 * @author Hughan.Kleintjes.hughanK@gmail.com
 */
public class SumVisitor implements NumberVisitor{
    
    @Override
    public void visit(TwoElement twoElement) {
        int sum = twoElement.a + twoElement.b;
        System.out.println(twoElement.a+"+"+twoElement.b+"="+sum);
    }
    
    @Override
    public void visit(ThreeElement threeElement) {
        int sum = threeElement.a+threeElement.b+threeElement.c;
        System.out.println(threeElement.a+"+"+threeElement.b+"="+sum);
    }
    
    @Override
    public void visit(List<NumberElement> elementList){
        for(NumberElement ne: elementList) {
            ne.accept(this);
        }
    }
    
}
